package org.sapp;

import java.sql.*;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.test.ejb.model.EmployeeController;

public class Main 
{	
	public static void main(String[] args) 
	{
		try
		{							
			EclipseLinkFactory eclipseLinkFactory = new EclipseLinkFactory("unitTest");
			eclipseLinkFactory.init();
			
			OpenEjbFactory ejbFactory = new OpenEjbFactory();
			ejbFactory.addDataSource(new DataSource("jdbc/TestJPA", 
					"com.mysql.jdbc.Driver",
					"jdbc:mysql://localhost:3306/jpa_test", "root", "vitalii")
			);
			ejbFactory.create();

			EmployeeController empc = (EmployeeController) ejbFactory.lookupLocal("EmployeeControllerRemote");
			empc.createEmployee("David", "williams");
			
			return;
		} 
		catch (Exception e)
		{
			e.printStackTrace();
		}			
	}
}
